1 Introduction

2 Australia maps

2.1 Package ozmaps

  • It provide the following map (all in form of sf class):
    • ozmaps::ozmap_states: state boundary
    • ozmaps::abs_ced: Commonwealth Electoral Divisions
    • ozmaps::abs_lga: Local Government Areas
library(sp)
library(sf)
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(ggplot2)

oz_states = ozmaps::ozmap_states
ggplot(oz_states) + 
  geom_sf() + 
  coord_sf()

oz_votes = ozmaps::abs_ced
ggplot() + 
  geom_sf(data = oz_votes) + 
  coord_sf()

lga = ozmaps::abs_lga
ggplot() + 
  geom_sf(data = oz_states, mapping = aes(fill = NAME), show.legend = FALSE) +
  geom_sf(data = lga, fill = NA) + 
  coord_sf() 

2.2 Victoria maps

  • Most shapefile can found in https://data.gov.au.
  • All LGA: VICLGA folder – 92 elements
  • All suburb: VICSub folder – 2973 elements
  • LGA in Greater Melbourne – 32 element (1st element is greater melbourne)

All datasets are read into as SpatialPolygonsDataFrame

library(rgdal)
library(sp)
VICLGA = readOGR(dsn = "datasets/VICLGA/VIC_LOCALITY_POLYGON_shp.shp", "VIC_LOCALITY_POLYGON_shp")
## Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
## dumpSRS, : Discarded datum Geocentric_Datum_of_Australia_1994 in CRS definition:
## +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\tingjinc\OneDrive - The University of Melbourne\Documents\GitFile\90122Lab\datasets\VICLGA\VIC_LOCALITY_POLYGON_shp.shp", layer: "VIC_LOCALITY_POLYGON_shp"
## with 92 features
## It has 10 fields
VICSub = readOGR(dsn="datasets/VICSub/VIC_LOCALITY_POLYGON_shp.shp", "VIC_LOCALITY_POLYGON_shp")
## Warning in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS =
## dumpSRS, : Discarded datum Geocentric_Datum_of_Australia_2020 in CRS definition:
## +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\tingjinc\OneDrive - The University of Melbourne\Documents\GitFile\90122Lab\datasets\VICSub\VIC_LOCALITY_POLYGON_shp.shp", layer: "VIC_LOCALITY_POLYGON_shp"
## with 2973 features
## It has 12 fields
MELLGA = readOGR(dsn = "datasets/Mel/Aus-Melbourne02.shp", "Aus-Melbourne02")
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\tingjinc\OneDrive - The University of Melbourne\Documents\GitFile\90122Lab\datasets\Mel\Aus-Melbourne02.shp", layer: "Aus-Melbourne02"
## with 32 features
## It has 14 fields
  • You will cut SpatialPolygons you wants – Essentially manipulation of SpatialPolygons.
  • One useful funciton in crop in package raster
    • crop(x, y)
  • crop returns a geographic subset of an object x as specified by an Extent object y
    • ?crop for more details
  • Here we will create
  • Task 1: all surburbs in Greater Melbourne
  • Task 2: all surburbs in City of Melbourne
library(raster)
library(mapview)
# Before crop, first check CRS
VICLGA@proj4string
## CRS arguments:
##  +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
VICSub@proj4string
## CRS arguments:
##  +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
MELLGA@proj4string
## CRS arguments: +proj=longlat +datum=WGS84 +no_defs
# Making all CRS the same
crs0 = VICLGA@proj4string
MELLGA = spTransform(MELLGA, crs0)
MELLGA@proj4string
## CRS arguments:
##  +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
## Task 1
GMEL = MELLGA[1, ]   # Greater Melbourne
GMELSub = crop(VICSub, GMEL)
mapView(GMELSub)      
## Task 2: this code takes a while to run. 
i = which(MELLGA$name == "City of Melbourne")
CMEL = MELLGA[i, ]
#CMELSub = crop(VICSub, CMEL)      
#mapView(CMELSub) 
#SReg = readOGR(dsn="datasets/PlanMelbourne/Administrative/State Regions_region.shp", "State Regions_region")

#library(mapview)
#mapView(SReg)
#CBD = readOGR(dsn="2_ggplot/PlanMelbourne/Central City Urban Renewal and Precincts/Central Business District_region.shp", "Central Business District_region")
#mapView(CBD)